﻿package com.sgcc.nfc.lock.data.local.mapper

import com.sgcc.nfc.lock.data.local.entity.WarningEntity
import com.sgcc.nfc.lock.domain.model.Warning
import com.sgcc.nfc.lock.domain.model.WarningStatus
import com.sgcc.nfc.lock.domain.model.WarningType

fun WarningEntity.toDomain(): Warning = Warning(
    warningId = warningId,
    warningType = WarningType.from(warningType),
    lockId = lockId,
    roomId = roomId,
    roomName = roomName,
    warningContent = warningContent,
    unlockDuration = unlockDuration,
    status = WarningStatus.from(status),
    handleUserId = handleUserId,
    handleUserName = handleUserName,
    handleTime = handleTime,
    createTime = createTime
)

fun Warning.toEntity(): WarningEntity = WarningEntity(
    warningId = warningId,
    warningType = warningType.code,
    lockId = lockId,
    roomId = roomId,
    roomName = roomName,
    warningContent = warningContent,
    unlockDuration = unlockDuration,
    status = status.code,
    handleUserId = handleUserId,
    handleUserName = handleUserName,
    handleTime = handleTime,
    createTime = createTime
)